<!DOCTYPE html>
<html lang="en">
<head>
    <title>添加就诊卡</title>
    <%- include('../../_global/baseLibs') %>
    <link rel="stylesheet" href="/quickJs/scripts/mui/css/mui.min.css">
    <script type="text/javascript" src="/quickJs/scripts/mui/js/mui.min.js"></script>
    <link rel="stylesheet" href="/quickJs/scripts/mui/mui.picker.min.css">
    <script type="text/javascript" src="/quickJs/scripts/mui/mui.picker.min.js"></script>
</head>
<body>
<section class="page-wrap page-family">

    <!-- header start -->
    <header id="header" class="header-box grey fixed"  >
        <div class="header-content">
            <div class="left-tool">
                <a class="back" href="javascript:void(0)"><i class="iconfont icon-back"></i></a>
            </div>
            <div class="title">添加就诊卡</div>
        </div>
    </header>
    <!-- header end -->
    <!--content start-->
    <section class="content">
        <aside class="plane-box first">
            <ul class="default-list form-list">
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                           就诊卡号
                        </div>
                        <div class="item-center">
                            <input class="input-text form-control" id="mediCardId" type="text" placeholder="请输入就诊卡卡号" value=""
                                   quick-config="label:'就诊卡号', validateProxy:'notNull length', length: '64'">
                        </div>
                    </div>
                </li>
                </li>
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            就诊卡类型
                        </div>
                        <div class="item-center">
                            <input id="jzCardType" class="input-text form-control" type="text" placeholder="必填" value=""
                                   quick-config="label:'就诊卡类型', validateProxy:'notNull length', length: '64'">
                            <i class="iconfont icon-more"></i>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            <span class="color-warring">设为默认就诊卡</span>
                        </div>
                        <div class="item-after">
                            <input id="isDefault" class="input-check" type="checkbox"/>
                        </div>
                    </div>
                </li>
            </ul>
        </aside>

        <aside class="button-box">
            <a class="button button-primary" id="btnBind">绑定就诊卡</a>
        </aside>

    </section>
    <!--content end-->

</section>

<script>

    var page_card = (function($, page_card) {
        /*保存就诊卡*/
        var uri_service_jzk_save = '/api/gzd/jzk/save';

        page_card.submit = submit;
        page_card.init = function(){
            var item = StoreCache.getCache('family_item');
            $("body").data("item", item);
            var picker = new mui.PopPicker();
            $('#jzCardType').click(function(){
                // 初始化数据
                var data = $.JkcsZydmUtils.getAry({tableName:"jzklx",textField:"text",valueField:"value"});
                picker.setData(data);
                /*弹出选择器 并传递关闭回调函数*/
                picker.show(function (selectItems) {
                    $("#jzCardType").attr("text",selectItems[0].value);
                    $("#jzCardType").attr("value",selectItems[0].text);
                });
            });
            $("#btnBind").on('click', submit);
        }

        function submit(){
            if($(".form-control").QuickValidate()){
                var params = {};
                var data = getData();
                params = $.extend(params, data);
                save(params);
            }
        }

        function getData(){
            var jbxx = $("body").data("item");
            var data = {};
            data['jmjbxxid'] = jbxx['jmjbxxid'];
            data['jzkh'] = $("#mediCardId").val();
            var jzklx = $("#jzCardType").attr("text");
//            var dict = $.JkcsZydmUtils.getDict({
//                tableName: 'jzklx'
//                ,keyValue: false
//            });
//            data['jzklx'] = dict[jzklx];
            data['jzklx'] = jzklx;
            data['sfmr'] = $("#isDefault").is(':checked')?"1":"0";
            return data;
        }

        function save(params){
            $.QuickRemote.AjaxJson({
                funcName: uri_service_jzk_save
                ,params: params
                ,callback: function(result){
                    var jmjbxxid = $.QuickUrlUtils.getRequest("jmjbxxid");
                    $.pageSwitch.goToUrl("family","familyInfo","jmjbxxid="+jmjbxxid,{animate:"pop"});
                }
            });
        }
        return page_card;
    })(jQuery, {})
</script>
</body>
</html>